package com.xhx.service.mongodb.impl;

import com.xhx.dao.mongodb.GisCoordinate;
import com.xhx.dao.mongodb.GisCoordinateMapper;
import com.xhx.model.utils.PagingModel;
import com.xhx.service.mongodb.GisCoordinateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 采用 MongoDB 数据库
 */
@Service("gisCoordinateService")
public class GisCoordinateServiceImpl implements GisCoordinateService {

    @Resource(description = "primaryGisCoordinateMapper")
    private GisCoordinateMapper gisCoordinateMapper;

    /**
     * 添加
     *
     * @param gisCoordinate 实体
     * @return
     */
    public long addGisCoordinate(GisCoordinate gisCoordinate) {
        // 级联
        return this.gisCoordinateMapper.addGisCoordinate(gisCoordinate);
    }

    /**
     * 删除
     *
     * @param id 主键
     */
    public long deleteGisCoordinateById(long id) {
        // 级联
        return this.gisCoordinateMapper.deleteGisCoordinateById(id);
    }

    /**
     * 修改
     *
     * @param gisCoordinate
     */
    public long updateGisCoordinateById(GisCoordinate gisCoordinate) {
        // 级联
        return this.gisCoordinateMapper.updateGisCoordinateById(gisCoordinate);
    }

    /**
     * 查找
     *
     * @param id 主键
     * @return
     */
    public GisCoordinate getGisCoordinateById(long id) {
        // 级联
        return this.gisCoordinateMapper.getGisCoordinateById(id);
    }

    /**
     * 列表，并分页
     *
     * @param pagingModel:分页模型
     * @param filterModel:过滤模型
     * @return 实体集
     */
    public List<GisCoordinate> getAllGisCoordinate(PagingModel pagingModel, GisCoordinate filterModel) {
        pagingModel.count = (int) (this.gisCoordinateMapper.getAllGisCoordinateCount(filterModel));
        if (pagingModel.count == 0) {
            return null;
        }

        // 级联
        return this.gisCoordinateMapper.getAllGisCoordinate(pagingModel, filterModel);
    }
}
